﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Hardware;
using Dcms.Config;


public partial class System_CheckSN : System.Web.UI.Page
{

    WebSiteConfigInfo etWebSiteConfigInfo = WebSiteConfigs.Deserialize("~/SystemConfig/WebSiteInfo.config");
    protected void Page_Load(object sender, EventArgs e)
    {
        labhost.Text = GetHost();
        labdisk.Text = GetMacID();
        if (!IsPostBack)
        {
            textSn.Text = "";
        }
          
    
    }
    protected void Page_Unload(object sender, EventArgs e)
    {
        Page.Session.Abandon();
      
       
    }

    /// <summary>
    /// 取到网卡
    /// </summary>
    /// <returns></returns>
    public static string GetMacID()
    {
        HardwareInfo hard = new HardwareInfo();
        return hard.GetMacAddress();

     
    }

    /// <summary>
    /// 取网站主机头
    /// </summary>
    /// <returns></returns>
    public static string GetHost()
    {
        return HttpContext.Current.Request.Url.Host.ToUpper();
    }

    protected void buttSetSN_Click(object sender, EventArgs e)
    {
        if (textSn.Text.Trim() != "")
        {
            etWebSiteConfigInfo.snCode = textSn.Text.Trim();
            WebSiteConfigs.Serialiaze(etWebSiteConfigInfo, "~/SystemConfig/WebSiteInfo.config");
            if (Request.QueryString["url"] != null && Request.QueryString["url"].ToString() != "")
            {
                Response.Redirect(Request.QueryString["url"].ToString());
                
            }
        }
    }
}
